home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / TUT1-9.ZIP / TUTPROG5.PAS < prev    next >
Pascal/Delphi Source File  |  1993-09-16  |  6KB  |  198 lines

  1. {$X+} {$R-}
  2. Uses Crt;
  3.  
  4. CONST VGA = $a000;
  5.       XSize = 16;
  6.       YSize = 16;
  7.  
  8. TYPE
  9.         Letter = Array[1..xsize,1..ysize] of Byte;
  10.         Letters = Array[' '..']'] of Letter;
  11.  
  12. VAR Font : ^Letters;
  13.  
  14. {──────────────────────────────────────────────────────────────────────────}
  15. Procedure SetMCGA;  { This procedure gets you into 320x200x256 mode. }
  16. BEGIN
  17.   asm
  18.      mov        ax,0013h
  19.      int        10h
  20.   end;
  21. END;
  22.  
  23.  
  24. {──────────────────────────────────────────────────────────────────────────}
  25. Procedure SetText;  { This procedure returns you to text mode.  }
  26. BEGIN
  27.   asm
  28.      mov        ax,0003h
  29.      int        10h
  30.   end;
  31. END;
  32.  
  33. {──────────────────────────────────────────────────────────────────────────}
  34. procedure WaitRetrace; assembler;
  35.   { This waits until you are in a Verticle Retrace }
  36.  
  37. label
  38.   l1, l2;
  39. asm
  40.     mov dx,3DAh
  41. l1:
  42.     in al,dx
  43.     and al,08h
  44.     jnz l1
  45. l2:
  46.     in al,dx
  47.     and al,08h
  48.     jz  l2
  49. end;
  50.  
  51. {──────────────────────────────────────────────────────────────────────────}
  52. Procedure Pal(ColorNo : Byte; R,G,B : Byte);
  53.   { This sets the Red, Green and Blue values of a certain color }
  54. Begin
  55.    Port[$3c8] := ColorNo;
  56.    Port[$3c9] := R;
  57.    Port[$3c9] := G;
  58.    Port[$3c9] := B;
  59. End;
  60.  
  61.  
  62. {──────────────────────────────────────────────────────────────────────────}
  63. Procedure PutPixel (X,Y : Integer; Col : Byte; Where : Word);
  64.    { This puts a pixel at X,Y using color col, on VGA or the Virtual Screen}
  65. BEGIN
  66.   Mem [Where:X+(Y*320)]:=col;
  67. END;
  68.  
  69. {──────────────────────────────────────────────────────────────────────────}
  70. procedure LoadPal (FileName : string);
  71.    { This loads the Pallette file and puts it on screen }
  72. type DACType = array [0..255] of record
  73.                                 R, G, B : byte;
  74.                               end;
  75. var DAC : DACType;
  76.     Fil : file of DACType;
  77.     I : integer;
  78. BEGIN
  79.   assign (Fil, FileName);
  80.   reset (Fil);
  81.   read (Fil, DAC);
  82.   close (Fil);
  83.   for I := 0 to 255 do Pal(I,Dac[I].R,Dac[I].G,Dac[I].B);
  84. end;
  85.  
  86. {──────────────────────────────────────────────────────────────────────────}
  87. function Exist(FileName: string): Boolean;
  88.     { Checks to see if filename exits or not }
  89. var f: file;
  90. begin
  91.   {$I-}
  92.   Assign(f, FileName);
  93.   Reset(f);
  94.   Close(f);
  95.   {$I+}
  96.   Exist := (IOResult = 0) and
  97.    (FileName <> '');
  98. end;
  99.  
  100.  
  101. {──────────────────────────────────────────────────────────────────────────}
  102. Procedure Setup;
  103.   { This loads the font and the pallette }
  104. VAR f:file;
  105.     loop1:char;
  106.     loop2,loop3:integer;
  107. BEGIN
  108.   getmem (font,sizeof (font^));
  109.   If exist ('softrock.fnt') then BEGIN
  110.     Assign (f,'softrock.fnt');
  111.     reset (f,1);
  112.     blockread (f,font^,sizeof (font^));
  113.     close (f);
  114.     Writeln ('SoftRock.FNT from TEXTER5 found in current directory. Using.');
  115.   END
  116.   ELSE BEGIN
  117.     Writeln ('SoftRock.FNT from TEXTER5 not found in current directory.');
  118.     For loop1:=' ' to ']' do
  119.       For loop2:=1 to 16 do
  120.         for loop3:=1 to 16 do
  121.           font^[loop1,loop2,loop3]:=loop2;
  122.   END;
  123.   If exist ('pallette.col') then
  124.     Writeln ('Pallette.COL from TEXTER5 found in current directory. Using.')
  125.   ELSE
  126.     Writeln ('Pallette.COL from TEXTER5 not found in current directory.');
  127.   Writeln;
  128.   Writeln;
  129.   Write ('Hit any key to continue ...');
  130.   readkey;
  131.   setmcga;
  132.   If exist ('pallette.col') then loadpal ('pallette.col');
  133. END;
  134.  
  135.  
  136. {──────────────────────────────────────────────────────────────────────────}
  137. Procedure ScrollMsg (Msg : String);
  138.   { This scrolls the string in MSG across the screen }
  139. Var Loop1,loop2,loop3 : Integer;
  140. Begin
  141.   For loop1:=1 to length (msg) do BEGIN
  142.     For loop2:=1 to xsize do BEGIN
  143.  
  144.       { This bit scrolls the screen by one then puts in the new row of
  145.         letters }
  146.  
  147.       waitretrace;
  148.       For Loop3 := 100 to 99+ysize do
  149.         move (mem[vga:1+(loop3*320)],mem[vga:(loop3*320)],319);
  150.       for loop3:=100 to 99+ysize do
  151.         putpixel (319,loop3,font^[msg[loop1],loop2,loop3-99],vga);
  152.            { Change the -99 above to the minimum of loop3-1, which you
  153.              will change in order to move the position of the scrolly }
  154.     END;
  155.  
  156.     {This next bit scrolls by one pixel after each letter so that there
  157.       are gaps between the letters }
  158.  
  159.     waitretrace;
  160.     For Loop3 := 100 to 99+ysize do
  161.       move (mem[vga:1+(loop3*320)],mem[vga:(loop3*320)],319);
  162.       for loop3:=100 to 99+ysize do
  163.         putpixel (319,loop3,0,vga);
  164.   END;
  165. End;
  166.  
  167.  
  168. BEGIN
  169.   ClrScr;
  170.   Writeln ('This program will give you an example of a scrolly. If the file');
  171.   Writeln ('SOFTROCK.FNT is in the current directory, this program will scroll');
  172.   Writeln ('letters, otherwise it will only scroll bars. It also searches for');
  173.   Writeln ('PALLETTE.COL, which it uses for it''s pallette. Both SOFTROCK.FNT');
  174.   Writeln ('and PALLETTE.COL come with TEXTER5.ZIP, at a BBS near you.');
  175.   Writeln;
  176.   Writeln ('You will note that you can change what the scrolly says merely by');
  177.   Writeln ('changing the string in the program.');
  178.   Writeln;
  179.   Setup;
  180.   repeat
  181.     ScrollMsg ('ASPHYXIA RULZ!!!   ');
  182.   until keypressed;
  183.   Settext;
  184.   freemem (font, sizeof (font^));
  185.   Writeln ('All done. This concludes the fifth sample program in the ASPHYXIA');
  186.   Writeln ('Training series. You may reach DENTHOR under the name of GRANT');
  187.   Writeln ('SMITH on the MailBox BBS, or leave a message to ASPHYXIA on the');
  188.   Writeln ('ASPHYXIA BBS. Get the numbers from Roblist, or write to :');
  189.   Writeln ('             Grant Smith');
  190.   Writeln ('             P.O. Box 270');
  191.   Writeln ('             Kloof');
  192.   Writeln ('             3640');
  193.   Writeln ('I hope to hear from you soon!');
  194.   Writeln; Writeln;
  195.   Write   ('Hit any key to exit ...');
  196.   Readkey;
  197. END.
  198.